package com.aidong.chat.action;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.json.annotations.JSON;
import org.springframework.beans.factory.annotation.Autowired;

import com.aidong.chat.biz.ChatLogBiz;
import com.aidong.chat.biz.FeedBackBiz;
import com.aidong.chat.entity.ChatLogEntity;
import com.aidong.chat.entity.FeedBackEntity;
import com.aidong.util.CalendarUtil;
import com.aidong.util.PageUtil;
import com.aidong.util.ReadPropertiesUtil;
import com.opensymphony.xwork2.ModelDriven;

/**
 *问题反馈
 * @author user
 *
 */
@ParentPackage("json")
@Namespace("/")
public class FeedBackAction implements ModelDriven<FeedBackEntity> {
	
	private FeedBackEntity feedback;
	
	@Override
	public FeedBackEntity getModel() {
		if(feedback == null){
			feedback = new FeedBackEntity();
		}
		return feedback;
	}
	
	private FeedBackBiz feedBackBiz;
	@Autowired
	public void setFeedBackBiz(FeedBackBiz feedBackBiz) {
		this.feedBackBiz = feedBackBiz;
	}
	
	
	private Map<String, Object> map;
	
	@JSON
	public Map<String, Object> getMap() {
		return map;
	}
	
	/**
	 * 添加问题反馈
	 * @return
	 */
	@Action(value="addFeedBack",results={@Result(name="succ",type="json",params={"root","map"})})
	public String addFeedBack(){
		map = new HashMap<String, Object>();
		try {
			feedBackBiz.addFeedBack(feedback);
		} catch (Exception e) {
			 e.printStackTrace();
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
		map.put("code", 1);
		map.put("msg", "反馈成功"); 
		return "succ";
	}
	
	
}
